<?php

namespace api\finance\controller;

use api\finance\model\MoneyChargeModel;

class MoneyChargeController extends \Aaa\finance\controller\MoneyChargeController {

    /**
     * @name 支付宝
     */
    public function alipay() {
        $model = new MoneyChargeModel($this->user);
        switch ($this->deviceType) {
            case 'pc'://PC
                $res = $model->alipayFaceToFace($this->param);
                $this->success('请求成功', $res);
                break;
            case 'mobile'://H5
                $res = $model->alipayWap($this->param);
                $this->success('请求成功', $res);
                break;
            case 'android'://android
            case 'iphone'://iOS
                if (cmf_get_option('system/api/alipay')['appRechargeMethod'] == 'wap') {
                    $res = $model->alipayWap($this->param);
                } else {
                    $res = $model->alipayApp($this->param);
                }
                $this->success('请求成功', $res);
                break;
            default:
                $this->error('未知设备类型');
        }
    }

    /**
     * @name 微信
     */
    public function wechatpay() {
        $model = new MoneyChargeModel($this->user);
        switch ($this->deviceType) {
            case 'pc'://PC
                $this->error('即将上线');
                break;
            case 'mobile'://H5
                $this->error('即将上线');
                break;
            case 'android'://android
            case 'iphone'://iOS
                $res = $model->wechatpayApp($this->param);
                $this->success('请求成功', $res);
                break;
            default:
                $this->error('未知设备类型');
        }
    }

    /**
     * @name Mo宝支付宝
     */
    public function mobaopayAlipay() {
        $model = new MoneyChargeModel($this->user);
        switch ($this->deviceType) {
            case 'pc'://PC
                $res = $model->mobaopay($this->param, 'alipay', 'pc');
                $this->success('请求成功', $res);
                break;
            case 'mobile'://H5
                $res = $model->mobaopay($this->param, 'alipay', 'mobile');
                $this->success('请求成功', $res);
                break;
            case 'android'://android
            case 'iphone'://iOS
                $res = $model->mobaopay($this->param, 'alipay', 'app');
                $this->success('请求成功', $res);
                break;
            default:
                $this->error('未知设备类型');
        }
    }

    /**
     * @name Mo宝微信
     */
    public function mobaopayWechatpay() {
        $model = new MoneyChargeModel($this->user);
        switch ($this->deviceType) {
            case 'pc'://PC
                $res = $model->mobaopay($this->param, 'wechatpay', 'pc');
                $this->success('请求成功', $res);
                break;
            case 'mobile'://H5
                $res = $model->mobaopay($this->param, 'wechatpay', 'mobile');
                $this->success('请求成功', $res);
                break;
            case 'android'://android
            case 'iphone'://iOS
                $res = $model->mobaopay($this->param, 'wechatpay', 'app');
                $this->success('请求成功', $res);
                break;
            default:
                $this->error('未知设备类型');
        }
    }

    //我只是个分界线，以上可以增加充值请求API
    public function ______() { }
    //以下可以增加其他API---------------


}
